﻿using System;
using System.Net;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;

namespace FeedTheWalrus
{
    public static class ScoreManager
    {
        public static int playerScore = 0;
        public static int health = 3;
        public static int highScore;

        static SpriteFont uifont;
        public static Texture2D healthBar;

        public static void OnNavigatedTo(ContentManager manager)
        {
            uifont = manager.Load<SpriteFont>("ui");
            healthBar = manager.Load<Texture2D>("health");
        }

        public static void OnUpdate(GameTimerEventArgs e)
        {


        }

        public static void OnDraw(SpriteBatch sb)
        {
            if (health == 3)
            {
                sb.Draw(healthBar, new Rectangle(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width - 200, SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Height - 150, healthBar.Width, healthBar.Height), Color.White);
                sb.Draw(healthBar, new Rectangle(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width - 150, SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Height - 150, healthBar.Width, healthBar.Height), Color.White);
                sb.Draw(healthBar, new Rectangle(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width - 100, SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Height - 150, healthBar.Width, healthBar.Height), Color.White);
            }
            else if (health == 2)
            {
                sb.Draw(healthBar, new Rectangle(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width - 200, SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Height - 150, healthBar.Width, healthBar.Height), Color.White);
                sb.Draw(healthBar, new Rectangle(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width - 150, SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Height - 150, healthBar.Width, healthBar.Height), Color.White);
            }
            else if (health == 1)
            {
                sb.Draw(healthBar, new Rectangle(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width - 200, SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Height - 150, healthBar.Width, healthBar.Height), Color.White);
            }
            else if (health == 0)
            {
                sb.DrawString(
                    uifont,
                    "GAME OVER",
                    new Vector2(
                        ((SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width / 2) - uifont.MeasureString("GAME OVER").X/2),
                        ((SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Height / 2) - uifont.MeasureString("GAME OVER").Y/2)),
                    Color.White);
            }


            sb.DrawString(
                uifont,
                "Score: " + playerScore,
                new Vector2(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width, SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Height)
                 - new Vector2(230, uifont.MeasureString("Score: ").Y),
                Color.White);
        }

        public static void OnNavigatedFrom()
        {

        }
    }
}
